<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	response.setHeader("cache-control","public");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <title>考务管理</title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/font/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/core.css">
    <link rel="stylesheet" href="<%=path%>/static/css/examMng/examMng.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/paperMng.css">
    <style type="text/css">
        .icob {
            float: right;
            margin-right: 20px;
            font-size: 20px;
        }
        input[type="radio"] {
            margin-left: 0px !important;
        }
    </style>
    <script src="<%=path%>/static/js/respond.js"></script>
    <script src="<%=path%>/static/js/jquery-1.9.1.min.js"></script>
    <script src="<%=path%>/static/js/bootstrap.min.js"></script>
    <script src="<%=path%>/static/js/examMng/right-btn.js"></script>
    <script src="<%=path%>/static/html2image/html2canvas.min.js"></script>
    <script src="<%=path%>/static/html2image/canvas2image.js"></script>
    <script src="<%=path%>/static/js/toImage/saveimg.js"></script>
</head>
<body>

<!--head begin-->
<jsp:include page="../head.jsp" flush="true"/>
    <!--head end-->
    <!--body begin-->
    <div id="container" class="main-container">
        <div class="container info-add body-box">
            <div class="info-add-box" style="background: #4c4ca6">
                <p>${paper.title}</p>
                <a href="javascript:history.go(-1);"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;返回</a>
            </div>
            <div style="padding-top: 20px">
                <p class="issue-title" style="margin-top: 20px;">试卷介绍</p>
                <div class="icob" title="打印预览" href="javascript:void(0);">
                    <img src="<%=path%>/static/images/document-print-preview.png" height="30" width="30">
                </div>
                <div class="bjbtn" style="display: none;right: 86px;height:125px;top: 244px;">
                    <div class="bjbtn_top"></div>
                    <div class="bjbtn_content">
                        <a href="#" onclick = "doPreview('no')">无答案打印</a>
                        <a href="#" onclick = "doPreview('yes')">有答案打印</a>
                        <a href="#" onclick = "doPreview('nopicn')">无图片无答案</a>
                        <a href="#" onclick = "doPreview('nopicy')">无图片有答案</a>
                    </div>
                </div>
                <div style="margin: 20px 20px 0 20px;">
                    <table class="issue-table" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td class="bcolor">${paper.title}</td>
                            <td width="15%" align="center" class="bcolor">分值：${paper.score}分</td>
                            <td width="15%" align="center">编写人:${creater}</td>
                        </tr>
                    </table>
                </div>
                <div class="view-container">
                    <!-- ------------------单选题 -------------------------- -->
                    <c:if test="${singlecount > 0}">
                        <div class="container-title">
                            <span class="font-weight">一、单选题</span>
                            <span class="fbt">（共${singlecount}道 ,每题${singlescore}分 ）</span>
                        </div>
                    </c:if>
                    <div class="view-content">
                        <c:forEach items="${singlelist}" var="question" varStatus="status">
                            <div class="view-box">
                                <div class="view-title">
                                    <div class="word">
                                        <span>${status.count}. ${question.title}</span>
                                    </div>
                                    <c:if test="${not empty question.picture && !(question.picture eq null) }">
                                        <img style="width: 200px;height: 250px;" src="<%=basePath%>${question.picture}"/>
                                    </c:if>
                                    <div class="rtitle">
                                    </div>
                                </div>
                                <div class="view-choose-box">

                                    <div class="radio">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.apic && !(question.apic eq null) }">
                                                    <p>A</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.apic }">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>A ${question.a}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.bpic && !(question.bpic eq null) }">
                                                    <p>B</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.bpic }">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>B ${question.b}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.cpic && !(question.cpic eq null) }">
                                                    <p>C</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.cpic}">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>C ${question.c}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.dpic && !(question.dpic eq null) }">
                                                    <p>D</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.dpic }">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>D ${question.d}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="answer-box">
                                        <span class="right-line"></span>
                                        <span>正确答案：<b>${question.answer}</b></span>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </div>
                    <!-- 多选题 -->
                    <c:if test="${muticount > 0}">
                        <div class="container-title">
                            <span class="font-weight">二、多选题</span>
                            <span class="fbt">（共${muticount}道 ,每题${mutiscore}分）</span>
                        </div>
                    </c:if>
                    <div class="view-content">
                        <c:forEach items="${mutilist}" var="question" varStatus="status">
                            <div class="view-box">
                                <div class="view-title">
                                    <div class="word">
                                        <span>${status.count + singlecount}. ${question.title}</span>
                                    </div>
                                    <c:if test="${not empty question.picture && !(question.picture eq null) }">
                                        <img style="width: 200px;height: 250px;" src="<%=basePath%>${question.picture}"/>
                                    </c:if>
                                    <div class="rtitle">
                                    </div>
                                </div>
                                <div class="view-choose-box">

                                    <div class="checkbox" style="margin-top: 6px;">
                                        <label class="choose" style="margin-bottom: 16px;">
                                            <input type="checkbox" style="margin-left: 0;" name="optionsRadios1"
                                                   id="optionsRadios2" value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.apic && !(question.apic eq null) }">
                                                    <p>A</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.apic}">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>A ${question.a}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="checkbox" style="margin-top: 6px;">
                                        <label class="choose" style="margin-bottom: 16px;">
                                            <input type="checkbox" style="margin-left: 0;" name="optionsRadios1"
                                                   id="optionsRadios2" value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.bpic && !(question.bpic eq null) }">
                                                    <p>B</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.bpic}">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>B ${question.b}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="checkbox" style="margin-top: 6px;">
                                        <label class="choose" style="margin-bottom: 16px;">
                                            <input type="checkbox" style="margin-left: 0;" name="optionsRadios1"
                                                   id="optionsRadios2" value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.cpic && !(question.cpic eq null) }">
                                                    <p>C</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.cpic}">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>C ${question.c}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="checkbox" style="margin-top: 6px;">
                                        <label class="choose" style="margin-bottom: 16px;">
                                            <input type="checkbox" style="margin-left: 0;" name="optionsRadios1"
                                                   id="optionsRadios2" value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.dpic && !(question.dpic eq null) }">
                                                    <p>D</p>
                                                    <img style="width: 120px; height: 120px;"  src="<%=basePath %>${question.dpic}">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>D ${question.d}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>

                                    <div class="answer-box">
                                        <span class="right-line"></span>
                                        <span>正确答案：<b>${question.answer}</b></span>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </div>
                    <!-- 判断题 -->
                    <c:if test="${judgecount > 0}">
                        <div class="container-title">
                            <span class="font-weight">三、判断题</span>
                            <span class="fbt">（共${judgecount}道 ,每题${judgescore}分）</span>
                        </div>
                    </c:if>
                    <div class="view-content">
                        <c:forEach items="${judgelist}" var="question" varStatus="status">
                            <div class="view-box">
                                <div class="view-title">
                                    <div class="word">
                                        <span>${status.count + singlecount + muticount}. ${question.title}</span>
                                    </div>
                                    <c:if test="${not empty question.picture && !(question.picture eq null) }">
                                        <img style="width: 200px;height: 250px;" src="<%=basePath%>${question.picture}"/>
                                    </c:if>
                                    <div class="rtitle">
                                    </div>
                                </div>
                                <div class="view-choose-box">

                                    <div class="radio" style="margin-top: 16px;">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.apic && !(question.apic eq null) }">
                                                    <p>${question.a}</p>
                                                    <img style="width: 120px; height: 120px;" src="<%=basePath %>${question.apic }">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>A ${question.a}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="radio" style="margin-top: 16px;">
                                        <label class="choose">
                                            <input type="radio" name="optionsRadios1" id="optionsRadios2"
                                                   value="option2" disabled>
                                            <c:choose>
                                                <c:when test="${not empty question.bpic && !(question.bpic eq null) }">
                                                    <p>${question.b}</p>
                                                    <img style="width: 120px; height: 120px;" src="<%=basePath %>${question.bpic }">
                                                </c:when>
                                                <c:otherwise>
                                                    <p>B ${question.b}</p>
                                                </c:otherwise>
                                            </c:choose>
                                        </label>
                                    </div>
                                    <div class="answer-box">
                                        <span class="right-line"></span>
                                        <span>正确答案：<b>${question.answer}</b></span>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--body end-->
<script>
    $(function () {
        // 试卷管理
        if (${role eq 'master'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else if (${role eq 'trainee'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else {
            $('#topMain').children().eq(4).addClass('active'); // 追加样式;
        }
    })
    $(document).ready(function () {
        $(".icob").click(function (event) {
            event.stopPropagation();
            if ($(".bjbtn").css("display") == "none") {
                $(".bjbtn").css("display", "block");
            } else {
                $(".bjbtn").css("display", "none");
            }
        });
    });
    function doPreview(str) {
        var myForm = document.createElement("form");
        myForm.method = "post";
        myForm.action = "<%=path%>/paper/printPreview";
        var myInput = document.createElement("input");
        myInput.setAttribute("name", "id");  // 为input对象设置name
        myInput.setAttribute("value", '${paper.id}');  // 为input对象设置value
        myForm.appendChild(myInput);
        var strInput = document.createElement("input");
        strInput.setAttribute("name", "answer");  // 为input对象设置name
        strInput.setAttribute("value", str);  // 为input对象设置value
        myForm.appendChild(strInput);
        document.body.appendChild(myForm);
        myForm.submit();
        document.body.removeChild(myForm); // 提交后移除创建的form
    }
</script>
</body>
</html>
